package com.bw.paper.mvp.view.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.bw.paper.App;
import com.bw.paper.R;
import com.bw.paper.entity.UserEntity;

public class ExitActivity extends AppCompatActivity
        implements View.OnClickListener {

    private Button exitBt;
    private ImageView headBackImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_exit);
        initView();
    }

    private void initView() {
        exitBt = (Button) findViewById(R.id.exit_bt);
        headBackImg = (ImageView) findViewById(R.id.head_back_img);
        exitBt.setOnClickListener(this::onClick);
        headBackImg.setOnClickListener(this::onClick);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.exit_bt) {
            App.getInstance().getDaoSession().deleteAll(UserEntity.class);
            Toast.makeText(this, "退出", Toast.LENGTH_SHORT).show();
//            startActivity(new Intent(this,LoginActivity.class));
            finish();
        }
        if (id == R.id.head_back_img) {
//            Intent intent = new Intent(this, FragmActivity.class);
//            startActivity(intent);
            finish();
        }
    }
}